package com.ayf.payment.game.api.service.platform.impl;

import com.ayf.payment.game.api.entity.platform.NetRechargeUrl;
import com.ayf.payment.game.api.mapper.platform.NetRechargeUrlMapper;
import com.ayf.payment.game.api.service.platform.NetRechargeUrlService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class NetRechargeUrlServiceImpl implements NetRechargeUrlService {

    @Resource
    private NetRechargeUrlMapper netRechargeUrlMapper;

    @Override
    public List<NetRechargeUrl> selectAll() {
        List<NetRechargeUrl> list=netRechargeUrlMapper.selectAll();
        if(list==null){
            return new ArrayList<NetRechargeUrl>();
        }
        return list;
    }

    @Override
    public void insertList(List<NetRechargeUrl> list) {
        if (!CollectionUtils.isEmpty(list)){
            list.forEach(item->{
                if (item.getId() == null){
                    netRechargeUrlMapper.insertSelective(item);
                } else {
                    netRechargeUrlMapper.updateByPrimaryKeySelective(item);
                }
            });
        }
    }

    @Override
    public void delNetRechargeUrlAllByIds(List<Integer> ids) {
        if (!CollectionUtils.isEmpty(ids)){
            netRechargeUrlMapper.delNetRechargeUrlAllByIds(ids);
        }
    }
}
